<?php

namespace App\Cms\Controller;

class Base extends \Controller {

    protected $authed_uid;

    protected $authed_user;

    public function init() {

        if ($this->authed_uid = $uid = \Auth::getAuthedUid('user')) {
            $this->authed_user = $user = QF()->User()->getInfo($uid);

            $this->assign([
                'authed_uid' => $uid,
                'authed_user' => $user,
            ]);
        }

        $columns = Cms()->Column()->getArray(1)['children'];
        foreach($columns as &$column) {
            if ($column['type'] != 'url') {
                $column['url'] = "/{$column['name']}";
            }
            if ($column['children']) {
                foreach($column['children'] as $key => $children_column) {
                    if ($children_column['type'] != 'url') {
                        $column['children'][$key]['url'] = $column['url'] . "/{$children_column['name']}";
                    }
                }
            }
        }
        unset($column);
        
        $this->navs = $columns;

        if (inMobile()) {
            $this->setViewPath('wap');
        } else {
            $this->setViewPath('web');
        }
    }

}
